<template>
  <div class="logintext">
    <van-field
      v-model="content"
      :label="label"
      :placeholder="placeholder"
      :type="type"
      :rule="rule"
    />
  </div>
</template>
<script>
export default {
  props: [
    'label', 'placeholder', 'type', 'rule'
  ],
  data: () => ({
    content: ''
  }),
  methods: {
    handlerelg () {
      const rule = new RegExp(this.rule)
      if (rule.test(this.content)) {
        this.$emit('inputChange', this.content)
      }
    }
  },
  watch: {
    content () {
      this.handlerelg()
    }
  }
}
</script>
<style lang="scss" scoped>
</style>
